#coding=utf-8
from TestWeb import mysql_connect

#从测试本地数据库中查询接口测试数据
def Get_testdatas(id,condition):
    connect = mysql_connect.mysql_connect()[0]  # connect是由connect_mysql函数返回的第一个值
    cursor = connect.cursor()
    # SQL 查询语句
    search_sql = "SELECT "+condition+" from mysql.test_data WHERE caseid ="+id
    # 执行sql语句
    cursor.execute(search_sql)
    result = cursor.fetchall()
    connect.commit()  # 实例提交命令
    result = str(result[0][0])
    #返回查询结果
    # print result
    return result

if __name__ == '__main__':
    expected = Get_testdatas('1', 'expected')
    print expected
    newexpected = eval(expected)
    code = newexpected["code"]
    print code